#ifndef PAGEHUMITURE_H
#define PAGEHUMITURE_H


#include <QWidget>
#include <QtGui>
#include <dialog.h>
#include <datamodel.h>
#include <QTimer>
#include <QtSerialPort/QSerialPort>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <QFile>
#include <unistd.h>
#include <myButton.h>

class PAGEHUMITURE : public QWidget
{
    Q_OBJECT
public:
    explicit PAGEHUMITURE(QWidget *parent = 0);

public:
    QByteArray sendBuf;

private:



    QTimer *Send_stop;
    QFont ft;
    QString style;
    int Timecount;
    bool isInTesting;
    bool stop_pressed;


    QLabel *labTestWd;
    QLabel *labTestSd;
    QTimer *labtime;  //定时器
    QTimer *labtime1;
    QTimer *labtime2;
   // QTimer *stateTime;
    int flag,flag1,flag2;
    void setDataStyle(QLabel *);
    QString findFloatStr(QByteArray str);

    void changeButton();//改变button图标
    void changeButton1();
    void changeButton2();

    QByteArray Analytical_data(QString,int,int );//传输设定的数据

    void readData(QByteArray);//读数据
    void readData1();

    void voice(int );
//    void voice1();
    myButton *start;
    myButton *start1;
    myButton *stop;

    void SaveConfig();
    void LoadConfig();



//*********************************************************
public:
    QWidget *widgetInfo;
    QLabel *labInfo;

    QSerialPort *serial;
    QSerialPort *serial1;

    bool debug_press;
    QLabel *labReternedBfb;
    QLabel *labReternedBc;
    QLabel *labReternedJc;
private:



    QLabel *dataBc;
    QLabel *dataJc;
    QLabel *dataBfb;

    QByteArray getdata;

    QLabel *statelabel;
    QLabel *limitlabel;
    QLabel *limitlabel1;
    QLabel *limitlabel2;

    QLabel *Vlabel;
    QLabel *showbfblabel;
    QLabel *bclabel;
    QLabel *jclabel;
    QLabel *bfblabel;

    QComboBox *danwei1;//单位
    QLabel *danwei2;
    QLabel *danwei3;
    QLabel *danwei4;
    QLabel *danwei5;

    QLineEdit *vEdit;
    QLineEdit *bcEdit;
    QLineEdit *jcEdit;
    QLineEdit *bfbEdit;

    QLabel *showbfbEdit;

    QPushButton *bcBtn1;//比差调节按钮
    QPushButton *bcBtn2;
    QPushButton *bcBtn3;
    QPushButton *bcBtn4;
    QPushButton *bcBtn5;
    QPushButton *bcBtn6;

    QPushButton *jcBtn1;//角差调节按钮
    QPushButton *jcBtn2;
    QPushButton *jcBtn3;
    QPushButton *jcBtn4;
    QPushButton *jcBtn5;
    QPushButton *jcBtn6;

    QPushButton *bfbBtn1;//百分表调节按钮
    QPushButton *bfbBtn2;

    QPushButton *VBtn1;//电压调节
    QPushButton *VBtn2;

    QPushButton *cu1;//粗细调节
    QPushButton *cu2;
    QPushButton *cu3;

    QPushButton *add1;//取反
    QPushButton *add2;


    QRadioButton *radio1;//单选框
    QRadioButton *radio2;
    QLabel *fen;
    QLabel *hu;
    Dialog *theKeyBoard;

    QTimer *timer_stop;


    QRadioButton *sinstate1;//坐标系单选框
    QRadioButton *sinstate2;
    QPushButton *sinlabel1;
    QPushButton *sinlabel2;
//*********************************************************

signals:
    void cmdSend();

public slots:
    void recvResult(QByteArray redata);
    //void startTest();
    void widgetInfoHide(){widgetInfo->hide();}

//*************************************************************
    void on_cu1_clicked();
    void on_cu2_clicked();
    void on_cu3_clicked();

    void on_bcBtn1_clicked();
    void on_bcBtn2_clicked();
    void on_bcBtn3_clicked();
    void on_bcBtn4_clicked();
    void on_bcBtn5_clicked();
    void on_bcBtn6_clicked();

    void on_jcBtn1_clicked();
    void on_jcBtn2_clicked();
    void on_jcBtn3_clicked();
    void on_jcBtn4_clicked();
    void on_jcBtn5_clicked();
    void on_jcBtn6_clicked();

    void on_bfbBtn1_clicked();
    void on_bfbBtn2_clicked();

    void on_VBtn1_clicked();
    void on_VBtn2_clicked();

    void on_AddBtn1_clicked();
    void on_AddBtn2_clicked();

    void labhide(){limitlabel->hide();}
    void labhide1(){limitlabel1->hide();}
    void labhide2(){limitlabel2->hide();}
    void colse_timer(){Send_stop->stop();}
    void on_start_chicked();
    void on_start1_chicked();
    void on_stop_chicked();

    void superior_limit();//限定范围
//    void superior_limit1();
    void sendData();
    void try_stop_testing();

    void state_on1(){sinstate1->setChecked(true);}
    void state_on2(){sinstate2->setChecked(true);}
protected:
    virtual bool eventFilter(QObject *watched, QEvent *e);


};


#endif // PAGEHUMITURE_H
